home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / platform.h < prev    next >
C/C++ Source or Header  |  2011-11-06  |  1KB  |  40 lines

  1. // ⁿPlatform.h
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #if !defined(_PLATFORM_INCLUDED_)
  6. #define _PLATFORM_INCLUDED_
  7.  
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11.  
  12. #ifdef _X86_
  13. // X86 allows unaligned accesses, so we can just dereference any pointer
  14. // after a cast
  15. #define GET16(pc)    (*(WORD *)(pc))
  16. #define GET32(pc)    (*(DWORD *)(pc))
  17. #define GET64(pc)    (*(DWORD64 *)(pc))
  18. #else // not _X86_
  19. // Other platforms (IPF and AMD64) either have a have a significant penalty
  20. // for unaligned accesses or they may trap to the OS).
  21. // For these platformsm we put the bytes together to make 16, 32 and 64 bit
  22. // objects.  We assume little-endian data.
  23. #define GET16(pc)    ((WORD)(*(unsigned char *)(pc)) |    \
  24.         ((*(unsigned char *)((pc) + 1)) << 8))
  25. #define GET32(pc)    ((DWORD)(*(unsigned char *)(pc)) |    \
  26.         ((*(unsigned char *)((pc) + 1)) << 8) |        \
  27.         ((*(unsigned char *)((pc) + 2)) << 16) |    \
  28.         ((*(unsigned char *)((pc) + 3)) << 24))
  29. #define GET64(pc)    ((DWORD64)(*(unsigned char *)(pc)) |    \
  30.         ((*(unsigned char *)((pc) + 1)) << 8) |        \
  31.         ((*(unsigned char *)((pc) + 2)) << 16) |    \
  32.         ((*(unsigned char *)((pc) + 3)) << 24) |    \
  33.         ((*(unsigned char *)((pc) + 4)) << 32) |    \
  34.         ((*(unsigned char *)((pc) + 5)) << 40) |    \
  35.         ((*(unsigned char *)((pc) + 6)) << 48) |    \
  36.         ((*(unsigned char *)((pc) + 7)) << 56))
  37. #endif // if _X86_ ... else not _X86_ ...
  38.  
  39. #endif // !defined(_PLATFORM_INCLUDED_)
  40.